﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using AspNetCs.Model;
using AspNetCs.Bll;
using AspNetCs.Common;

public partial class Users_AncestralHallBBSBottom : BasePage
{
    AncestralHallBBSBLL bll = new AncestralHallBBSBLL();
    protected int AncestralHallId = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserExit("Login.Aspx", "请您登录", true);
        if (!IsPostBack)
        {
            if (string.IsNullOrEmpty(Request["id"]))
            {
                ResultStr("Login.aspx", "参数错误");
            }
            else
            {
                ViewState["Id"] = Request["id"];
                this.AncestralHallId = StringHelper.isNumber_int(Request["id"]);
            }
            Bind();
        }
        else
        {
            if (ViewState["Id"] != null)
            {
                this.AncestralHallId = StringHelper.isNumber_int(ViewState["Id"].ToString());
            }
        }

    }

    protected void Bind()
    {
        //Users_Model userModel = Base_GetUserInfo;
        //if (userModel.UserId <= 0)
        //{
        //    ResultStr("AncestralHallList.aspx", "无访问权限!");
        //}
        //else
        //{
        //    if (userModel.UserId != StringHelper.isNumber_int(dataTable.Rows[0]["CreateId"].ToString()))
        //    {
        //        ResultStr("AncestralHallList.aspx", "该祠堂不是您创建的，无访问权限!");
        //    }
        //}
        DataTable dataTable = bll.getAncestralHallBBSByAncestralHallId(this.AncestralHallId, "BBSBottom", 0);
        string tempBBsBottom = "";
        tempBBsBottom = "<TABLE height=143 cellSpacing=0 cellPadding=0 width=954>";
        tempBBsBottom += "<TBODY><TR><TD width=954 height=143><P align=center><SPAN style=\"FONT-SIZE: 30px\"><B>{0}</B></SPAN></P></TD></TR></TBODY></TABLE>";
        if (dataTable != null)
        {
            if (dataTable.Rows.Count > 0)
            {
                string BBSBottom = dataTable.Rows[0]["BBSBottom"].ToString();
                string temp = BBSBottom;
                if (BBSBottom == "")
                {
                    BBSBottom =  "版权设置";
                }
                tempBBsBottom = string.Format(tempBBsBottom, BBSBottom);

                if (temp != "")
                {
                    tempBBsBottom = BBSBottom;
                }
                WebEditor1.Text = tempBBsBottom;
            }
        }
    }

    protected void btnCreate_Click(object sender, EventArgs e)
    {

        AncestralHallBBS_Model model = new AncestralHallBBS_Model();
        model.AncestralHallId = this.AncestralHallId;
        model.BBSBottom = WebEditor1.Text;
        bll.UpdateBottomContent(model);
        ResultStr("AncestralHallBBSBottom_" + this.AncestralHallId + ".aspx", "修改成功!");
    }
}
